var router   = require('express').Router();
var express  = require('express');
var app      = express();

var Building = require('./Building.js')

/**
 * get api/v1/tree/:id
 * 根据小区ID提供树状结构 满级
 */
router.get('/tree/:id',function(req,res){
    const communityId = req.params.id;
    Building.getCommunityTreeData(communityId,function(data){
        res.jsonp(data);
    })
})

/**
 * get api/v1/device/:id
 * 根据设备ID提供树状结构 栋和室级 和 户主信息
 */
router.get('/device/:id',function(req,res){
    const deviceId = req.params.id;
    Building.getDeviceTreeData(deviceId,function(data){
        res.jsonp(data);
    })
})

/**
 * get api/v1/manbuilding/:id
 * 根据用户ID提供房屋列表包括房屋名称
 */
router.get('/manbuilding/:id',function(req,res){
    const justManId = req.params.id;
    Building.getManTree(justManId,function(data){
        res.jsonp(data);
    });
})

module.exports = router;
